package com.polylink.sys.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

import com.mapper.SqlMapper;
import com.polylink.base.Page;
import com.polylink.sys.bean.Role;
import com.polylink.sys.dao.sqlProvider.RoleSqlProvider;

/**
 *@author xiliang.xiao
 *@date 2015年3月23日 上午9:03:57
 *
 **/
public interface IRoleDao extends SqlMapper{

	@Insert("Insert into cti_web_role (rolename,remark) "
			+ "value(#{name},#{remark})")
	public int add(Role role);

	@SelectProvider(type=RoleSqlProvider.class,method="list")
	public abstract List<Role> list(Page p) ;

	@SelectProvider(type=RoleSqlProvider.class,method="count")
	public int count(Page p);

	@Update("update cti_web_role set rolename=#{name},remark=#{remark} where id=#{id}")
	public int update(Role role);

	@Delete("delete from cti_web_role where id in (${id})")
	public int delete(@Param("id")String id);

	@Select("select role_id,function_id from cti_web_role_function where role_id=#{roleId}")
	public List<Map<String, Object>> getRoleFun(String roleId);

	@Insert("insert into cti_web_role_function(role_id,function_id) value(#{roleId},#{id})")
	public void addRoleFunction(@Param("roleId")String roleId, @Param("id")String id);

	@Delete("delete from cti_web_role_function where role_id=#{roleId} and function_id=#{id}")
	public void delRoleFunction(@Param("roleId")String roleId, @Param("id")String id);

}
